# Maintainer: Sébastien Luttringer

pkgname=ext4magic
pkgver=0.3.2
pkgrel=4
pkgdesc='Recover deleted or overwritten files on ext3 and ext4 filesystems'
arch=('loong64' 'x86_64')
url='https://sourceforge.net/projects/ext4magic/'
license=('GPL2')
depends=('bzip2' 'file' 'util-linux' 'e2fsprogs')
source=("$url/files/$pkgname-$pkgver.tar.gz"
        "$url/files/Patches/workaround.patch"
        '01-i_dir_acl.patch'
        '02-Fix-undefined-reference-to-makedev.patch')
md5sums=('8351cb27598fb8ffa7d2175ab74e7a53'
         'e96c1fff3b8d59f93a0557b0a8190167'
         '7e3462b64d142ee3911e67fcd9610f18'
         'bba42512e1da183f3897df43d2d2bc31')

prepare() {
  cd $pkgname-$pkgver
  # apply patch from the source array (should be a pacman feature)
  local filename
  for filename in "${source[@]}"; do
    if [[ "$filename" =~ \.patch$ ]]; then
      msg2 "Applying patch ${filename##*/}"
      patch -p1 -N -i "$srcdir/${filename##*/}"
    fi
  done
  :
}

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr --sbindir=/usr/bin
  make
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
}

# vim:set ts=2 sw=2 et:
